package com.DAO;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DatabaseConnection {
    public Connection getconn(String url,String user,String password) throws Exception{
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/"+url,user,password);
            return  conn;
        } catch (Exception e) {
            throw e;
        }
    }
    public void release(Connection connection,Statement statement){
        try {
            connection.close();
            statement.close();
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public void release(Connection connection, Statement statement, ResultSet resultSet){
        try {
            connection.close();
            statement.close();
            resultSet.close();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
